package com.itheima.pattern.factory.config_factory;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class Test {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Properties pro = new Properties();

        InputStream is = Test.class.getClassLoader().getResourceAsStream("bean.properties");

        pro.load(is);

        String latte = pro.getProperty("latte");

        Class clazz = Class.forName(latte);


        Constructor constructor = clazz.getConstructor();

        LatteCoffee o = (LatteCoffee) constructor.newInstance();

        String name = o.getName();
        System.out.println(name);


    }
}
